﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AcmeSportsStore
{
    public partial class NewPasswordView : Form
    {
        public NewPasswordView()
        {
            InitializeComponent();
        }

        private void btnOk_NPF_Click(object sender, EventArgs e)
        {
            AccountsStore.NewPasswordResult npr = AccountsStore.NewPassword(
                    tBoxName_NPF.Text, tBoxOldPassword_NPF.Text,
                    tBoxNewPassword1_NPF.Text, tBoxNewPassword2_NPF.Text);

            if (npr == AccountsStore.NewPasswordResult.Successful)
            {
                MessageBox.Show("Account '" + tBoxName_NPF.Text
                    + "' has successfully been created/renewed!", this.Owner.Text);
                this.Close();
            }
            else if (npr == AccountsStore.NewPasswordResult.WrongOldPassword)
            {
                MessageBox.Show("The Old password is't correct, input again.", this.Owner.Text);
            }
            else if (npr == AccountsStore.NewPasswordResult.TwoPasswordsNotSame)
            {
                MessageBox.Show("You input two different passwords for the new password.", this.Owner.Text);
            }
        }

        private void btnCancel_NPF_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void NewPasswordView_Load(object sender, EventArgs e)
        {
            tBoxName_NPF.Text = "";
            tBoxNewPassword1_NPF.Text = "";
            tBoxNewPassword2_NPF.Text = "";
            tBoxOldPassword_NPF.Text = "";
        }
    }
}
